//
//  ZYCTeacherDineStatisticsCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/28.
//

#import "ZYCTeacherDineStatisticsCell.h"
#import "ZYCTeacherDineStatiscModel.h"

@interface ZYCTeacherDineStatisticsCell()

@property (nonatomic, strong) UILabel *monthLabel;
@property (nonatomic, strong) NSArray *colorArray;


@end
@implementation ZYCTeacherDineStatisticsCell

- (void)setModel:(ZYCTeacherDineStatiscModel *)model{
    _model = model;
    _monthLabel.text = model.month;

    

    for (NSInteger i = 0; i < model.typeNameAndCount.count; i++) {
        ZYCTeacherDinnerModel *m = model.typeNameAndCount[i];
        CGFloat w = (kScreenWidth - 20 - 55) / model.typeNameAndCount.count;
        UILabel *lab = [[UILabel alloc] init];
        lab.font = kCustomFont(@"PingFangSC-Light", 14.0f);
        if ([model.month isEqualToString:@"小计:"]) {
            lab.text = m.count;
        }else{
            lab.text = m.typeAndCount;
        }
        lab.numberOfLines = 0;
        lab.textAlignment = NSTextAlignmentCenter;
        lab.textColor = self.colorArray[i % 3];
        [self.contentView addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(w);
            make.left.equalTo(self.monthLabel.mas_right).offset(10.0f + i * w);
            make.centerY.equalTo(self.contentView);
        }];
    }

}

- (NSArray *)colorArray {
    if (!_colorArray) {
        _colorArray = @[HEX_RGB(@"#EB9F28"),HEX_RGB(@"#39A85B"),HEX_RGB(@"#395AD2")];
    }
    return _colorArray;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.monthLabel];

        [self.monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(20.0f);
            make.centerY.equalTo(self.contentView);
            make.width.mas_equalTo(55.0f);
        }];
        

    }
    return self;
}

- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 17.0f) titleColor:HEX_RGB(@"#262A28") textAlignment:ZZTextAlignmentLeft];
    }
    return _monthLabel;
}



@end
